/*******************************************************************
 *
 * Copyright (C), 2021-2022, LS, All rights reserved.
 *
 * Author      : 
 * Create Time : 2021-09-22
 * Version     : v0.1
 * Description : 
 *******************************************************************/
 
/*----------------------------Head file----------------------------*/
#include "osal_app.h"
#include "hal_motor.h"
#include "app_motor.h"
#include "app_global_data.h"

#define APP_MOTOR_LOG_EN        0

#if APP_MOTOR_LOG_EN
#include "log.h"
#define APP_MOTOR_LOG           LOG
#else
#define APP_MOTOR_LOG(...)
#endif

/*----------------------------macro file---------------------------*/
#define MOTOR_STOP_TIMER_START(ms)      osal_start_timerEx(osalApp_TaskID, APP_MOTOR_STOP_TIMER_EVT, ms)

/*----------------------------type define--------------------------*/

/*----------------------------var define---------------------------*/

/*-------------------------func declaration------------------------*/

/*-----------------------------------------------------------------*/

void app_motor_init(void)
{
    hal_motor_stop();
}


void app_motor_start(uint16_t ms)
{
    if(false == g_app_data.sys.state.motor_running) {
        hal_motor_start();
        g_app_data.sys.state.motor_running = true;
        MOTOR_STOP_TIMER_START(ms);
    }
}


void app_motor_stop(void)
{
    if(true == g_app_data.sys.state.motor_running) {
        hal_motor_stop();
        g_app_data.sys.state.motor_running = false;
    }
}
